package com.example.transvipm;

import com.example.dbclass.DBHelper;

import android.net.Uri;
import android.os.Bundle;
import android.os.Vibrator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;
import android.widget.TextView;

public class Actualidad extends Activity {

	private DBHelper dbcc;
	private TextView num;
	private String Numero;
	private Vibrator vib;
	private ImageButton v_menu;
	private WebView webView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.actualidad);
		dbcc = new DBHelper(getApplicationContext());
		num = (TextView) findViewById(R.id.numero_movil);
		Bundle Datos = getIntent().getExtras();
		Numero = Datos.getString("Numero");
		num.setText(Numero);
		vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
		v_menu = (ImageButton) findViewById(R.id.Volver_menu);
		
		webView = (WebView) findViewById(R.id.webActualidad);
		webView.setWebViewClient(new MyWebViewClient());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.loadUrl("http://wspublic.transvip.cl/navegador/bin/actualidad_ver.php");

		
		v_menu.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				vib.vibrate(300);
				onBackPressed();
			}
		});

		v_menu.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				if (event.getAction() == MotionEvent.ACTION_DOWN) {

					v_menu.setImageResource(R.drawable.menu_pressed);

				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					v_menu.setImageResource(R.drawable.menu);

				}

				return false;
			}
		});
	}
	private class MyWebViewClient extends WebViewClient {
		    @Override
		    public boolean shouldOverrideUrlLoading(WebView view, String url) {
		      
		        return false;
		    }
		}

}
